#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int is_Excalibur(int* arr, int* ch)
{
	int count = 0;
	for (int h = 0; h < 7; h++)
	{
		for (int n = 0; n < 7; n++)
		{
			if (*(arr+h) == *(ch+n))
			{
				count++;
			}
		}
	}
	return count;
}


int ch[8];
int arr[8];
int fff[7];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < 7; i++)
	{
		scanf("%d", &ch[i]);
	}
	int j = 0;
	for (j = 0; j < n; j++)
	{
		for (int k = 0; k < 7; k++)
		{
			scanf("%d", &arr[k]);
		}
		int ret = is_Excalibur(&arr, &ch);
		fff[7 - ret] += 1;
		
	}
	for (int h = 0; h < 7; h++)
	{
		printf("%d ", fff[h]);
	}

	return 0;
}